
package swa08.ui;

import swa08.client.CustomClient;
import java.io.*;
import java.util.Scanner;


public class ClientConsole
{
    public static void main(String args[]) throws Exception
	{
		CustomClient client = new CustomClient("1001030");
        
        int auswahl = 0;
        Scanner s;
        
        do
        {
        	System.out.print("Auswahl (1=send)(2=receive)(3=list)(0=quit): ");
        	
        	s = new Scanner(System.in);
        	auswahl = s.nextInt();
        	
        	switch(auswahl)
        	{
        		case 1:
        			System.out.print("Message: ");
        			s.nextLine();
        			String message = s.nextLine();
        			System.out.print("Receiver-ID: ");
        			String id = s.nextLine();
        			System.out.print("Receiver-ProviderID: ");
        			String providerID = s.nextLine();
        			System.out.print("Receiver-ProviderEndpoint: ");
        			String providerEndpoint = s.nextLine();
        			if (client.sendMessage(message, id, providerID, providerEndpoint))
        			{
        				System.out.println("Message sent!");
        			}
        			else
        			{
        				System.out.println("Sending failed!");
        			}
        			break;
        		case 2:
        			System.out.println(client.pullMessages().toString());
        			break;
        		case 3:
        			System.out.println(client.listClients().toString());
        			break;
        	}
        	
        } while (auswahl != 0);
        
        client.destroy();
    }
}

